package com.baturu.offlineFord;

import com.baturu.ford.carvin.dal.ImageInfoDAO;
import com.baturu.offlineFord.dto.V2ImageInfoDTO;
import com.baturu.vin.constant.VinConstant;
import com.baturu.vin.test.AbstractBaseCase;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Author: chenjiahao
 * @Time: 2019/3/26
 */
public class ImageInfo extends AbstractBaseCase{

    @Autowired
    ImageInfoDAO imageDAO;
    @Test
    public void testName() throws Exception {
        imageDAO.createImageInfo();
        Integer maxId = imageDAO.queryMaxId();
        Integer start = 0;
        for (Integer i = 0; i < maxId; i++) {
            if (i%10000==0){
                List<V2ImageInfoDTO> v2ImageInfoDTOs = imageDAO.queryImageInfo(start, i);
                if (CollectionUtils.isNotEmpty(v2ImageInfoDTOs)) {
                    imageDAO.insertV2ImageInfoDTO(v2ImageInfoDTOs);
                }
                start = i;
            }
        }
        List<V2ImageInfoDTO> v2ImageInfoDTOs = imageDAO.queryImageInfo(start, maxId);
        if (CollectionUtils.isNotEmpty(v2ImageInfoDTOs)) {
            imageDAO.insertV2ImageInfoDTO(v2ImageInfoDTOs);
        }
    }


}
